package sicnu.cs.ich.activity.rest;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import sicnu.cs.ich.activity.service.IActivityService;
import sicnu.cs.ich.api.common.ResultInfo;
import sicnu.cs.ich.api.common.annotations.OperLog;
import sicnu.cs.ich.api.common.enums.OperEnum;
import sicnu.cs.ich.api.domain.dto.CallDTO;
import sicnu.cs.ich.api.domain.form.PageParam;
import sicnu.cs.ich.api.domain.vo.ActivityDetailVO;
import sicnu.cs.ich.common.util.ResultInfoUtil;

/**
 * @author 黎琦
 * @date 2021-11-25 16:33
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/auth/call")
@Api(tags = {"AUTH-号召相关操作"})
public class AuthCallResource {
    private final IActivityService activityService;

    @GetMapping("/list")
    @ApiOperation("获取号召列表")
    public ResultInfo<PageInfo<CallDTO>> activities(PageParam param){
        if(param==null){
            return ResultInfoUtil.buildError("没有页号和每页显示条数哦");
        }
        return ResultInfoUtil.buildSuccess(activityService.getAllCall(param));
    }

    @GetMapping("/detail")
    @ApiOperation("获取号召详情")
    public ResultInfo<ActivityDetailVO> getActivityDetail(@RequestParam("callID") Integer aid){
        if(aid==null){
            return ResultInfoUtil.buildError("缺少活动id参数");
        }
        return ResultInfoUtil.buildSuccess(activityService.getActivityDetail(aid));
    }
}
